import { ImageResponse } from 'next/og';
import { Fallback, Wallpaper } from '@/components/brand/og';
import { apiD1, safe } from '@/lib/api';
import { fmtDate, fmtParams, fmtTokens, num } from '@/lib/format';
import { routes, SITE_NAME } from '@/lib/site';
export const runtime = 'nodejs';
export const alt = `Model on ${SITE_NAME}`;
export const size = { width: 1200, height: 630 };
export const contentType = 'image/png';
/** Per-model Open Graph image: wallpaper with "Model · Org", name, identity subtitle and counters params · active · context · released. */
export default async function ModelOgImage({ params }: { params: Promise<{ slug: string }> }) {
const { slug } = await params;
const d = await safe(apiD1.model(slug));
if (!d || d.entity_type === 'artifact') return new ImageResponse(, { ...size });
const a = d.attributes ?? {};
const counters: [string, string][] = [];
if (num(a.parameter_count) !== null) counters.push(['Parameters', fmtParams(a.parameter_count)]);
if (num(a.active_parameter_count) !== null && num(a.active_parameter_count) !== num(a.parameter_count)) counters.push(['Active', fmtParams(a.active_parameter_count)]);
if (num(a.context_length) !== null) counters.push(['Context', `${fmtTokens(a.context_length)} tokens`]);
if (typeof a.release_date === 'string') counters.push(['Released', fmtDate(a.release_date)]);
const licence = d.licence && 'key' in d.licence && d.licence.key ? d.licence.key : null;
const subtitle = [d.openness?.label ?? null, licence ? `licence ${licence}` : null, d.deployments?.length ? `${d.deployments.length} provider deployment${d.deployments.length === 1 ? '' : 's'}` : null, d.benchmarks?.items.length ? `${d.benchmarks.items.length} benchmarks` : null].filter(Boolean).join(' · ') || d.description?.slice(0, 110) || 'Specifications, prices, benchmarks, lineage and sources.';
return new ImageResponse(, { ...size });
}